package com.demo.understandmvc.返回值处理.responseEntity;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class Controller {

	@RequestMapping("/modelattr/{name}")
	@ResponseBody
	public ResponseEntity<MyData> myResponseEntity() {
		// ResponseEntity可以同时设置HttpHeaders与ResponseBody，可以额外设置响应状态码
		return ResponseEntity.status(HttpStatus.OK)
				.header("test", "For Test")
				.body(new MyData());
	}

}
